<template>
  <el-input
    v-model="acctNoText"
    :placeholder="placeholder"
    :disabled="disabled"
    @input="handleInput"
    @change="inputChange"
  />
</template>
<script>
import {inputNumberAndLetter} from "@/utils/number";

export default {
  name: "AcctNoInput",
  model: {
    prop: "inputValue",
    event: "changeValue",
  },
  props: {
    inputValue: {},
    placeholder: {
      type: String,
      default: "",
    },
    disabled: {
      type: Boolean,
      default: false,
    },
    format: {
      type: String,
      default: '16'
    }
  },
  watch: {
    inputValue: {
      immediate: true,
      deep: true,
      handler(data) {
        if (data) this.acctNoText = data;
        else {
          this.acctNoText = "";
        }
      },
    },
  },
  data() {
    return {
      acctNoText: "",
    };
  },
  mounted() {
  },
  methods: {
    inputChange(input) {
      this.$emit("changeValue", input);
    },
    handleInput (val) {
      let number = inputNumberAndLetter(val)
      this.acctNoText = number
      let value = ''
      if (number === '-' || number === '.') {
        value = ''
      } else if (number !== '') {
        value = Number(inputNumberAndLetter(number))
      }
      this.$emit('input', value)
    }
  },
};
</script>
<style>
</style>
